﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Blizzard.Container;

namespace Blizzard.Contracts
{
    
        public class BList<T> : List<T> //where T: IDataObject 
        {

            private IDataObject _holder;

            private BList()
            {


            }

            public BList(IDataObject Holder)
            {
                _holder = Holder;
            }

            /// <summary>
            /// Its just like Add but it does not intercept the action
            /// </summary>
            /// <param name="item"></param>
            internal void InternalAdd(T item)
            {
                base.Add(item);
            }

            public virtual new void Add(T item)
            {
                base.Add(item);
                if(_holder != null)
                Flows.Flow_BListSetterRelationCreator(_holder, (IDataObject)item);
            }



            public virtual new void Remove(T item)
            {

                RelationInstance ri = 
                RelationInstanceContainer.GetRi(_holder, (IDataObject)item);
                Flows.Flow_BreakOrRemoveRelation(ri);

            }

            public virtual new void RemoveAt(int index)
            {
                //ToDo
            }






        }


  
}
